/*     */ package dm.jdbc.driver;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.CnvtInfo;
/*     */ import dm.jdbc.dataConvertion.Convertion;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import dm.jdbc.dbaccess.DmMsgSend;
/*     */ import dm.sql.DmdbDateTime;
/*     */ import dm.sql.DmdbTime;
/*     */ import java.sql.Date;
/*     */ import java.sql.SQLException;
/*     */ import java.sql.Time;
/*     */ import java.sql.Timestamp;
/*     */ 
/*     */ public class DmLongBinder
/*     */   extends DmBinder
/*     */ {
/*     */   public DmLongBinder(DmdbPreparedStatement_bs pstmt)
/*     */   {
/*  19 */     super(pstmt);
/*     */   }
/*     */   
/*     */   void init()
/*     */   {
/*  24 */     this.recDType = 8;
/*  25 */     this.recPrec = 8;
/*  26 */     this.recScale = 0;
/*     */   }
/*     */   
/*     */   public int bindData(DmMsgSend msg, int irow, int icol, boolean forBatch) throws SQLException
/*     */   {
/*  31 */     long x = ((long[])this.pstmt.m_paramObjects[icol])[irow];
/*  32 */     String serverEncoding = this.pstmt.connection.getServerEncoding();
/*  33 */     CnvtInfo cnvtInfo = this.pstmt.connection.getCnvtInfo();
/*  34 */     short dbTz = cnvtInfo.getDbTz();
/*  35 */     short ltz = cnvtInfo.getTimeZone();
/*     */     
/*  37 */     byte[] ret = toDbBytes(x, this.destDType, this.destPrec, this.destScale, serverEncoding, ltz, dbTz);
/*     */     
/*  39 */     return msg.appendBytesWithLen2(ret, 0, ret.length);
/*     */   }
/*     */   
/*     */   public static byte[] toDbBytes(long x, int destDType, int destPrec, int destScale, String serverEncoding, short ltz, short dbTz)
/*     */     throws SQLException
/*     */   {
/*  45 */     byte[] ret = null;
/*  46 */     switch (destDType)
/*     */     {
/*     */     case 8: 
/*  49 */       ret = Convertion.longToByteArray(x);
/*  50 */       break;
/*     */     
/*     */     case 3: 
/*     */     case 13: 
/*  54 */       ret = Convertion.booleanToByteArray(x != 0L);
/*  55 */       break;
/*     */     
/*     */     case 5: 
/*  58 */       if ((x > 127L) || (x < -128L)) {
/*  59 */         DBError.throwSQLException(6004);
/*     */       }
/*  61 */       ret = Convertion.byteToByteArray((byte)(int)x);
/*  62 */       break;
/*     */     
/*     */     case 6: 
/*  65 */       if ((x > 32767L) || (x < -32768L)) {
/*  66 */         DBError.throwSQLException(6004);
/*     */       }
/*  68 */       ret = Convertion.shortToByteArray((int)x);
/*  69 */       break;
/*     */     
/*     */     case 7: 
/*  72 */       if ((x > 2147483647L) || (x < -2147483648L)) {
/*  73 */         DBError.throwSQLException(6004);
/*     */       }
/*  75 */       ret = Convertion.IntToByteArray((int)x);
/*  76 */       break;
/*     */     
/*     */     case 10: 
/*  79 */       ret = Convertion.floatToByteArray((float)x);
/*  80 */       break;
/*     */     
/*     */     case 11: 
/*  83 */       ret = Convertion.doubleToByteArray(x);
/*  84 */       break;
/*     */     
/*     */     case 9: 
/*     */     case 24: 
/*  88 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), destPrec, destScale);
/*  89 */       break;
/*     */     
/*     */     case 0: 
/*     */     case 1: 
/*  93 */       ret = Convertion.String_char_2CType(String.valueOf(x), destPrec, destDType, serverEncoding);
/*  94 */       break;
/*     */     
/*     */     case 2: 
/*     */     case 19: 
/*  98 */       ret = 
/*  99 */         Convertion.String_varchar_2CType(String.valueOf(x), destPrec, destDType, serverEncoding);
/* 100 */       break;
/*     */     
/*     */     case 17: 
/* 103 */       ret = Convertion.longToBinary(x, destPrec);
/* 104 */       break;
/*     */     case 16: 
/* 106 */       if (x > 255611203200L) {
/* 107 */         DBError.throwSQLException(63024);
/*     */       }
/* 109 */       DmdbDateTime ts = new DmdbDateTime(new Timestamp(x * 1000L - 
/* 110 */         2209017600000L).toString(), destScale, 2);
/* 111 */       ret = Convertion.TimeStampToByteArray(ts, destDType, destScale, dbTz, ltz);
/* 112 */       break;
/*     */     
/*     */     case 15: 
/* 115 */       ret = Convertion.TimeToByteArray(new DmdbTime(String.valueOf(new Time(x * 1000L)), 
/* 116 */         destScale));
/* 117 */       break;
/*     */     
/*     */     case 14: 
/* 120 */       if (x > 2958463L) {
/* 121 */         DBError.throwSQLException(63024);
/*     */       }
/* 123 */       DmdbDateTime dt = new DmdbDateTime(new Date(x * 24L * 60L * 60L * 1000L - 
/* 124 */         2209017600000L).toString(), destScale, 0);
/* 125 */       ret = Convertion.DateToByteArray(dt);
/* 126 */       break;
/*     */     case 4: case 12: case 18: case 20: 
/*     */     case 21: case 22: case 23: default: 
/* 129 */       DBError.throwSQLException(6007);
/*     */     }
/*     */     
/* 132 */     return ret;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmLongBinder.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */